﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WingbotDriver
{
    class WingJson
    {
        public uint id { get; set; }
        public uint cnt { get; set; }
        public object data { get; set; }
    }

    class ClientData
    {
        public double retarding { get; set; }
        public double MaxVel { get; set; }
        public double AngleDiff { get; set; }
        public double KeepYawOffset { get; set; }
        public bool EnableTmpTf { get; set; }
        public double TmpX { get; set; }
        public double TmpY { get; set; }
        public double TmpYaw { get; set; }
    }

    class PidJson:WingJson
    {
        public new bool data { get; set; }
    }

    class ClientJson:WingJson
    {
        /// <summary>
        /// 客户端发过来的，包装在 msgid = 1 的消息里面
        /// </summary>
        public new ClientData data { get; set; }
    }

    class AckJson:WingJson 
    {
        public new bool data { get; set; }
        public AckJson(uint cnt, bool reply)
        {
            data = reply;
            this.cnt = cnt;
        }
    }

    public class SpeedData
    {
        public int mode { get; set; }
        public double vx { get; set; }
        public double vy { get; set; }
        public double vth { get; set; }
        public double shiftAng { get; set; }
        public double shiftMps { get; set; }
        public int spinRpm { get; set; }
    }

    public class ArmData
    {
        public bool Stretch { get; set; }
        public bool DrawBack { get; set; }
        public bool Pump { get; set; } 
    }

    public class RaiseData
    {
        public bool Down { get; set; }
        public bool Up { get; set; }
        public bool Pump { get; set; }
    }

    public class StateData
    {
        public bool PidBusy { get; set; }
        public bool PidEnable { get; set; }
        public int RunMode { get; set; }
        /// <summary>
        /// 主车or从车，0-未分配，1-前车，2-后车
        /// </summary>
        public int TeamRole { get; set; }
        /// <summary>
        /// 0-Moving, 1-Spin, 2-Shifting
        /// </summary>
        public int CtrlMode { get; set; }
        public double TeamDistance { get; set; }
        public int KeepYaw { get; set; }
        public double x { get; set; }
        public double y { get; set; }
        public double yaw { get; set; }
        /// <summary>
        /// L开头的是局部坐标
        /// </summary>
        public double Lx { get; set; }
        public double Ly { get; set; }
        public double Lyaw { get; set; }
        public double vx { get; set; }
        public double vy { get; set; }
        /// <summary>
        /// 速度幅值，表明车子在前进还是后退
        /// </summary>
        public double v { get; set; }
        public double vth { get; set; }
        public double battery { get; set; }
        public int ArmState { get; set; }
        public int RaiseState { get; set; }
        public int RfidState { get; set; }
        public string RfidData { get; set; }
    }

    class AddOdomData
    {
        public double x { get; set; }
        public double y { get; set; }
        public double yaw { get; set; }
        public bool reset { get; set; }
    }

    class MoveToPointData
    {
        public int RunMode { get; set; }
        public bool ManualStop { get; set; }
        public uint task_id { get; set; }
        public double dx { get; set; }
        public double dy { get; set; }
        public double x { get; set; }
        public double y { get; set; }
        public double yaw { get; set; }
    }

    class GoToXYThData
    {
        public uint task_id { get; set; }
        public double dx { get; set; }
        public double dy { get; set; }
        public double dth { get; set; }
    }

    class ModeData
    {
        public int RunMode { get; set; }
        public double TeamDistance { get; set; }
    }

    class SetOdomData
    {
        public int source { get; set; }
        public double x { get; set; }
        public double y { get; set; }
        public double yaw { get; set; }
    }

    class SpeedJson:WingJson
    {
        public new SpeedData data { get; set; }
    }

    class StateJson:WingJson
    {
        public new StateData data { get; set; }
        public StateJson()
        {
            data = new();
        }
    }

    class ModeJson:WingJson
    {
        public new ModeData data { get; set; }
    }

    class AddOdomJson:WingJson
    {
        public new AddOdomData data { get; set; }
    }

    class MoveToPointJson: WingJson
    {
        public new MoveToPointData data { get; set; }
    }

    class ArmJson:WingJson
    {
        public new ArmData data { get; set; }
    }

    class RaiseJson:WingJson
    {
        public new RaiseData data { get; set; }
    }

    class GoToXYThJson:WingJson
    {
        public new GoToXYThData data { get; set; }
    }

    class SetOdomJson:WingJson
    {
        public new SetOdomData data { get; set; }
    }
}
